/*
    created: 2020/3/30
    filename: Factory.cpp
    author: 李东霖
    purpose: Factory模式的代码演示
*/
#include"Factory.h"
#include<iostream>

using namespace std;

//实现我们的Product极其派生类

ConcreateProduct::ConcreateProduct()
{
    std::cout<<"construction of ConcreateProduct"<<std::endl;
}

ConcreateProduct::~ConcreateProduct()
{
    std::cout<<"destruction of ConcreateProduct"<<std::endl;
}

//实现工厂基类和他的派生类
Creator::Creator()
{
    std::cout<<"construction of Creator"<<std::endl;
}
Creator::~Creator()
{
    std::cout<<"destruction of Creator"<<std::endl;

}
void Creator::AnOperation()
{
    Product* p = FactoryMethod();
    std::cout<<"an operation of product"<<std::endl;
    delete p;
    p = nullptr;
}
//工厂派生类成员的实现
ConcreateCreator::ConcreateCreator()
{
    std::cout<<"construction of ConcreateCreator"<<std::endl;
}
ConcreateCreator::~ConcreateCreator()
{
    std::cout<<"destruction of ConcreateCreator"<<std::endl;
}
Product* ConcreateCreator::FactoryMethod()
{
    return new ConcreateProduct();
}